package pers.fulsun.es.test;

import java.io.IOException;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class _01_ESClient  {

  public static RestHighLevelClient getClient() {

    RestHighLevelClient client = new RestHighLevelClient(
        RestClient.builder(
            // 9200 端口为Elasticsearch 默认的Web 通信端口
            new HttpHost("localhost", 9200, "http")
        )
    );
    return client;
  }

  public static void main(String[] args) throws IOException {
    RestHighLevelClient client = getClient();
    System.out.println(client);
    // 关闭客户端连接
    client.close();
  }
}